package com.ghck.server.dao;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ghck.server.dao.provider.TestQuestionProvider;
import com.ghck.server.model.TestQuestion;
import com.ghck.server.model.query.TestQuestionQuery;
import com.ghck.server.model.response.TestQuestionRes;
 public interface TestQuestionMapper {
 	
 	/**
 	*根据id删除 测试题
 	*/
 	@Delete("delete from t_test_question where id=#{id}")
 	public Integer deleteById(Integer id);
 	
 	/**
 	* 批量新增 测试题
 	*/
 	@InsertProvider(method="batchInsert",type=TestQuestionProvider.class)
	@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="list[0].id")
 	public Integer batchInsert(List<? extends TestQuestion> testQuestions);
 	
 	/**
 	* 新增 测试题
 	*/
 	@InsertProvider(method="insert",type=TestQuestionProvider.class)
	@Options(useGeneratedKeys=true)
 	public Integer insert(TestQuestion domain);
 
 	
 	/**
 	*更新 测试题
 	*/
 	@UpdateProvider(method="update",type=TestQuestionProvider.class)
 	public Integer update(TestQuestion domain);
 	
 	/**
 	*根据ID查询 测试题
 	*/
	@Select("select * from t_test_question where id=#{id}")
	public TestQuestion findById(Integer id);
	
	/**
 	*通过query 查询 测试题
 	*/
 	@SelectProvider(method="findByQuery",type=TestQuestionProvider.class)
 	public List<TestQuestion> findByQuery(TestQuestionQuery query);
 	
 	/**
 	*通过query count总条数
 	*/
 	@SelectProvider(method="countByQuery",type=TestQuestionProvider.class)
 	public Integer countByQuery(TestQuestionQuery query);
 	
 	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findByIds",type=TestQuestionProvider.class)
 	public List<TestQuestion> findByIds(List<Integer> ids);
 	
 	/**
 	 * 通过category_id查询题目
 	 * @param categoryId
 	 * @return
 	 */
 	@Select("select * from t_test_question where in_used=1 and category_id=#{categoryId}")
 	public List<TestQuestionRes> findByCategoryId(Integer categoryId);
}	